//
//  KDAccountSaveController.m
//  WangJingApp
//
//  Created by 魏强 on 17/11/21.
//  Copyright © 2017年 KDTech. All rights reserved.
//

#import "KDAccountSaveController.h"
#import "WQRightImageBtn.h"
#import "KDChangePwdController.h"
@interface KDAccountSaveController ()

@end
static NSString *cellId =@"AccountSaveCell";

@implementation KDAccountSaveController
#pragma mark - 懒加载区

#pragma mark - 生命周期区
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"帐号安全";
    [self setupTableView];
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = NO;
    
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    self.navigationController.navigationBar.hidden = YES;
    
}
#pragma mark - 板块布置区
- (void)setupTableView{
    self.tableView.tableFooterView = [UIView new];
    self.tableView.separatorColor = WQColor(244, 244, 244);
    self.tableView.top = 10;
    //1.调整(iOS7以上)表格分隔线边距
    if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
        self.tableView.separatorInset = UIEdgeInsetsZero;
    }
    //2.调整(iOS8以上)view边距(或者在cell中设置preservesSuperviewLayoutMargins,二者等效)
    if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
        self.tableView.layoutMargins = UIEdgeInsetsZero;
    }
//    [self.tableView registerClass:[KDClearCacheCell class] forCellReuseIdentifier:ClearCacheCellId];
    
}
#pragma mark - 事件点击区
- (void)btnClick:(UIButton *)btn{
    KDChangePwdController *change = [[KDChangePwdController alloc]init];
    [self.navigationController pushViewController:change animated:YES];

}
#pragma mark - 网络请求区

#pragma mark - 通知接收区


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:cellId];
    if (cell == nil)
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
//        cell.accessoryType = UITableViewCellAccessory;
    }
    if (indexPath.row == 0) {
        KDAccount *account = [KDAccountTool account];
        
        cell.textLabel.text = @"账号";
        UILabel *label = [[UILabel alloc]init];
        label.text = account.userName;
        [label sizeToFit];
        label.textColor = WQColor(95, 204, 165);
        label.font = [UIFont systemFontOfSize:14];
        cell.accessoryView =label;
    }else{
        cell.textLabel.text = @"密码";
        WQRightImageBtn *btn = [WQRightImageBtn buttonWithType:UIButtonTypeCustom];
        btn.frame = CGRectMake(0, 0, 100, 44);
        [btn setTitle:@"修改密码" forState:UIControlStateNormal];
        [btn setImage:[UIImage imageNamed:@"rightArrow"] forState:UIControlStateNormal];
        [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];

        [btn setTitleColor:KDColor forState:UIControlStateNormal];
        cell.accessoryView = btn;
    }
    //2.调整(iOS8以上)tableView边距(与上面第2步等效,二选一即可)
    if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
        cell.preservesSuperviewLayoutMargins = NO;
    }
    //3.调整(iOS8以上)view边距
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }

    // Configure the cell...
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row ==1) {
        KDChangePwdController *change = [[KDChangePwdController alloc]init];
        [self.navigationController pushViewController:change animated:YES];
    }
}
/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Table view delegate

// In a xib-based application, navigation from a table can be handled in -tableView:didSelectRowAtIndexPath:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic may go here, for example:
    // Create the next view controller.
    <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:<#@"Nib name"#> bundle:nil];
    
    // Pass the selected object to the new view controller.
    
    // Push the view controller.
    [self.navigationController pushViewController:detailViewController animated:YES];
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
